﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

namespace FITHOU_EDU_Server.mobile
{
    public partial class UpdateCalendar : System.Web.UI.Page
    {
        //global
        public int PK_iLichhocID;
        public int iTrangthai;
        String sqlCon = ConfigurationManager.ConnectionStrings["FITHOU_EDU"].ToString();
        //-------------------------------------------------
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                PK_iLichhocID = int.Parse(Request.QueryString["PK_iLichhocID"].ToString());
                iTrangthai = int.Parse(Request.QueryString["iTrangthai"].ToString());
                Response.Write(CallUPdateCalendar());
            }
            catch(Exception ex)
            {
                Response.Write("Server: Không xác định được tham số PK_iLichhocID hoặc iTrangthai");
            }
        }

        public Boolean CallUPdateCalendar()
        {
            Boolean bRes = true;

            SqlConnection Con = new SqlConnection(sqlCon);
            SqlCommand cmd = new SqlCommand();
            SqlDataAdapter adapter = null;
            try
            {
                Con.Open();
                cmd.CommandText = "sp_tblLichhoc_update_iTrangthai";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection = Con;
                cmd.Parameters.Add("@PK_iLichID", SqlDbType.Int);
                cmd.Parameters.Add("@iTrangthai", SqlDbType.Int);
                cmd.Parameters[0].Value = PK_iLichhocID;
                cmd.Parameters[1].Value = iTrangthai;
                adapter = new SqlDataAdapter(cmd);
                int iRes = cmd.ExecuteNonQuery();
                if (iRes > 0)
                {
                    bRes = true;
                }
                else
                {
                    bRes = false;
                }
            }
            catch (Exception e)
            {
                Response.Write(e.Message);
            }
            finally
            {
                if (Con.State != ConnectionState.Closed)
                    Con.Close();
                Con.Dispose();
            }

            return bRes;
        }

    }
}